﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace H
{
	// Token: 0x02000267 RID: 615
	internal class H_State_PreInsertWait : H_State
	{
		// Token: 0x0600102E RID: 4142 RVA: 0x00067C2C File Offset: 0x00065E2C
		public H_State_PreInsertWait(H_Members members) : base(members)
		{
		}

		// Token: 0x0600102F RID: 4143 RVA: 0x00067C38 File Offset: 0x00065E38
		public override void In(H_State.Message msg)
		{
			this.members.param.mouth = H_MOUTH.FREE;
			if ((this.members.StyleData.detailFlag & 4096) != 0)
			{
				base.ChangeState(H_STATE.INSERT);
				return;
			}
			float blend = H_State.BlendMessage.GetBlend(msg, 0f);
			this.members.PlayAnime("PreInsertWait", blend);
			this.leaveTimer = 0f;
			this.leave = false;
			this.endInVoice = false;
			this.members.MaleExpression(H_Expression_Male.TYPE.NORMAL);
			this.members.EnableTinIK = false;
		}

		// Token: 0x06001030 RID: 4144 RVA: 0x00067CC8 File Offset: 0x00065EC8
		public override void Main()
		{
			this.leaveTimer += Time.deltaTime;
			if (!this.leave && this.leaveTimer >= 10f)
			{
				int femaleNo = UnityEngine.Random.Range(0, this.members.GetFemales().Count);
				this.members.VoiceExpression(femaleNo, H_Voice.TYPE.LEAVING);
				this.leave = true;
			}
			this.UpdateVoice();
			if (this.endInVoice && this.members.h_scene.MixCtrl.mode == MixController.MODE.FULL_AUTO)
			{
				base.ChangeState(H_STATE.INSERT);
			}
		}

		// Token: 0x06001031 RID: 4145 RVA: 0x00067D64 File Offset: 0x00065F64
		private void UpdateVoice()
		{
			List<Female> females = this.members.GetFemales();
			for (int i = 0; i < females.Count; i++)
			{
				if (!females[i].IsVoicePlaying())
				{
					this.endInVoice = true;
					this.members.VoiceExpression(i, H_Voice.TYPE.BREATH);
				}
			}
		}

		// Token: 0x06001032 RID: 4146 RVA: 0x00067DBC File Offset: 0x00065FBC
		public override void OnInput(H_INPUT input)
		{
			if (input == H_INPUT.CLICK_PAD)
			{
				base.ChangeState(H_STATE.INSERT);
			}
		}

		// Token: 0x04001173 RID: 4467
		private const float leaveTime = 10f;

		// Token: 0x04001174 RID: 4468
		private float leaveTimer;

		// Token: 0x04001175 RID: 4469
		private bool leave;

		// Token: 0x04001176 RID: 4470
		private bool endInVoice;
	}
}
